package com.qls.web.modules.ht.controller;

import com.qls.core.entity.HtHotel;
import com.qls.core.utils.R;
import com.qls.mt.api.MtRemoteService;
import com.qls.web.common.utils.PageUtils;
import com.qls.web.modules.ht.service.HtHotelinfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

/**
 * @author doyoung
 */
@RestController
@RequestMapping("ht/hthotelinfo")
public class HtHotelinfoController {

    @Autowired
    private MtRemoteService mtRemoteService;

    @Autowired
    private HtHotelinfoService htHotelinfoService;

    /**
     * 列表
     *
     * @return R
     */
    @RequestMapping("/list")
    @RequiresPermissions("ht:hthotelinfo:list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = htHotelinfoService.sqlQueryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     *
     * @return R
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("ht:hthotelinfo:info")
    public R info(@PathVariable("id") Long id) {
        HtHotel htHotelinfo = htHotelinfoService.getById(id);
        return R.ok().put("htHotelinfo", htHotelinfo);
    }

    /**
     * 保存
     *
     * @return R
     */
    @RequestMapping("/save")
    @RequiresPermissions("ht:hthotelinfo:save")
    public R save(@RequestBody HtHotel htHotelinfo) {
        htHotelinfoService.save(htHotelinfo);
        return R.ok();
    }

    /**
     * 修改
     *
     * @return R
     */
    @RequestMapping("/update")
    @RequiresPermissions("ht:hthotelinfo:update")
    public R update(@RequestBody HtHotel htHotelinfo) {
        htHotelinfoService.updateById(htHotelinfo);
        return R.ok();
    }

    /**
     * 删除
     *
     * @return R
     */
    @RequestMapping("/delete")
    @RequiresPermissions("ht:hthotelinfo:delete")
    public R delete(@RequestBody Long[] ids) {
        htHotelinfoService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }
}
